package com.dstz.crm.rest.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.dstz.base.api.aop.annotion.CatchErr;
import com.dstz.base.api.query.QueryFilter;
import com.dstz.base.api.query.QueryOP;
import com.dstz.base.api.response.impl.ResultMsg;
import com.dstz.base.core.util.StringUtil;
import com.dstz.base.db.model.page.PageResult;
import com.dstz.base.rest.BaseController;
import com.dstz.base.rest.util.RequestUtil;
import com.dstz.crm.core.manager.NoticeManager;
import com.dstz.crm.core.model.Customer;
import com.dstz.crm.core.model.CustomerFollowup;
import com.dstz.crm.core.model.Notice;
import com.dstz.sys.util.ContextUtil;
import com.github.pagehelper.Page;



/**
 * 案例 控制器类<br/>
 * @author  aschs
 * </pre>
 */
@RestController
@RequestMapping("/crm/notice")
public class NoticeController extends BaseController<Notice>{
	@Resource
	NoticeManager noticeManager;

	@Override
	protected String getModelDesc() {
		
		return "公告";
	}
	
	/**
     * 保存产品表信息
     */
    @RequestMapping("save")
    @Override
    @CatchErr
    public ResultMsg<String> save( @RequestBody Notice notice) throws Exception {
        
    	noticeManager.saveNotice(notice);
        return getSuccessResult(notice.getId(), "保存成功");
    }
    
    /**
     * 分页列表
     */
    @RequestMapping("myListJson")
    public PageResult myListJson(HttpServletRequest request, HttpServletResponse response) throws Exception {
    	QueryFilter queryFilter = getQueryFilter(request);
		List<Notice> noticeList = noticeManager.getByUserId(queryFilter);
		return new PageResult(noticeList);
	}
	
    @RequestMapping("stick")
    @CatchErr
    public ResultMsg<String> top(@RequestParam String id,@RequestParam Boolean isTop) throws Exception {
    	noticeManager.stick(id,isTop);
        return getSuccessResult("成功");
    }
}
